home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
bathints.zip
/
BH_02.DOC
< prev
next >
Wrap
Text File
|
1987-10-26
|
4KB
|
101 lines
BAT-HINT # 2
**************************************************************************
from the BATHINTS library... part of the BATPOWER CONFERENCE from:
THE PAINFRAME OPUS/FIDO 261/1004
Baltimore, Maryland 1-301-488-7461
**************************************************************************
The ECHO and REM commands
The ECHO command has several interesting features and performs in a
specific manner under a variety of conditions:
1. The ECHO command is normally used to inhibit the display of
batch file command lines. Most batch files start with the command:
ECHO OFF
The same command isuued at the DOS prompt will also inhibit the
display of the DOS prompt.
2. If a batch file is called from another batch file when ECHO was off
in the first batch file, ECHO will also be turned off in the second
batch file, unless the second batch file is called as a string
after loading another command processor (see BAT-HINT #1 for an
explanation of secondary command processors). For example, in the
first two examples shown below, echo will automatically be off
in the second batch file:
FIRST.BAT SECOND.BAT
echo off ....
.... ....
.... ....
....
second
In the following two examples, ECHO will be on in the second batch
file:
FIRST.BAT SECOND.BAT
echo off ....
.... ....
.... ....
....
command /c second
....
....
where .... is meant to represent any other command on a line.
3. When ECHO is off, remarks entered after the PAUSE command are not
displayed. When ECHO is on, the PAUSE command may be followed by a
remark that will be diplayed on the monitor (along with the word
pause!).
The REM command in DOS is very simple. It simply displays a remark entered
after the REM command. If ECHO is on, the remark (and the word REM!) are
displayed. If echo is off, neither the remark nor the REM command are
displayed. It is useful for including explanatory remarks in batch files.
Remarks can be entered in another way however. Since DOS does not display
batch file command lines starting with a colon (:), preceeding a command
line or a remark will inhibit the display and execution of that command
line. Normally the colon is used to identify a batch file label. However,
the colon can be of great use in the development of batch files and for
troubleshooting the execution of batch files. For example, if the bat file
shown below (sample.bat) was used to load several memory resident programs
(memres1, memres2, memres3) and a problem was encountered when trying to
perform some other function, the command lines in question could be hidden
from execution by inserting a colon in front of the command line. The
system could then be rebooted and the bat file run with one line hidden to
test the effect of loading that memres program (memres2 in sample.bat shown
below). Using the colon in this manner, one need only remove the colon,
rather than retyping the command line over again, to restore the bat file
to its original sequence of commands.
SAMPLE.BAT
echo off
cd\memprog
memres1
:memres2
memres3
cd\
Beware however that if the bat file in question contains sveral goto
commands and :labels, the inclusion of unreferenced labels in this manner
will slow the execution of the batch file. Furthermore, care should be
taken to avoid a conflict between the first eight letters of referenced
labels and the first eight letters of command lines hidden with a colon
(unreferenced labels). Users of DOS 2.X should use a single period (.)
rather than a colon, in the example shown above.
******************************************************* David Creasey